'**************************************************************************
'**************************************************************************
DECLARE SUB InitialIzation
DECLARE SUB BadOpSys
DECLARE SUB Notadmini
DECLARE SUB Disinsentive
DECLARE SUB FindOldSoftWare
DECLARE SUB ASKEXIT
DECLARE SUB GetPath
DECLARE SUB QuitInstall
DECLARE SUB FillCopyList
DECLARE SUB FillIniFile
DECLARE SUB AddIfVersion (szSec$, szKey$, szSrc$, szDest$)
DECLARE SUB UpDateIniKeyValue (szIni$, szSec$, szKey$, szVal$)
DECLARE FUNCTION WriteDisToFile LIB "mscuistf.dll" (Direct$) AS INTEGER
DECLARE FUNCTION ReadIniDisin   LIB "mscuistf.dll" (Direct$) AS INTEGER
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION IsWinNT LIB "mscuistf.dll" AS INTEGER
DECLARE FUNCTION Launch32 LIB "mscuistf.dll" (szDir$) AS INTEGER
DECLARE FUNCTION FindWindow LIB "USER" (classname$, title$) AS INTEGER
DECLARE FUNCTION SetFocus LIB "USER" (x%) AS INTEGER
DECLARE FUNCTION SwapMouseButton LIB "USER" (x%) AS INTEGER
DECLARE FUNCTION GetString LIB "mscuistf.dll" (x%) AS INTEGER
DECLARE FUNCTION SetRunLine LIB "mscuistf.dll" (lpNewLine$) AS INTEGER
DECLARE FUNCTION Copy3D LIB "mscuistf.dll" (szThe$) AS INTEGER
DECLARE FUNCTION SetSchemes LIB "mscuistf.dll" (szThe$) AS INTEGER
DECLARE FUNCTION RegisterWindowMessage LIB "USER" (sz$) AS INTEGER

CONST DIS_NOT_INSTALLED = 101
CONST DIS_INSTALLED = 202
CONST DIS_CORUPTED = 303

'**************************************************************************
'**************************************************************************
SUB InitialIzation STATIC

    x% = GetString(8002)
    sz$ = GetSymbolValue("SetupString")
    SetTitle sz$
    RemoveSymbol "SetupString"
    SetBitmap COMDLL$, 1

    '' Read setup.inf file
    szSTR$ = GetSymbolValue("STF_SRCINFPATH")
    IF szSTR$ = "" THEN
        szSTR$ = GetSymbolValue("STF_CWDDIR")
    END IF
    SETUPINF$ = szSTR$
    ReadInfFile szSTR$ + "setup.inf"

    '' Find the Mother ship
    HWIN% = FindWindow("SETUP", "SETUP")
    
    '' Get source dir
    SRCDIR$ = GetSymbolValue("STF_SRCDIR")

    '' Disincentive
    RetCode% = ReadIniDisin(SRCDIR$ + "setup.ini")

    '' Get windows type
    WINTYPE% = IsWinNT

    IF WINTYPE% = -1 THEN
        BADOPS% = 500
        BadOpSys
    ELSEIF WINTYPE% = 0 THEN
        WINTYPE% = GetWindowsMajorVersion
        IF WINTYPE% = 3 THEN
            x% = GetWindowsMinorVersion
            IF x% = 0 THEN
                BADOPS% = 550
                BadOpSys
            ENDIF

            IF x% > 12 THEN
                WINTYPE% = 4
            ENDIF

        ENDIF
        IF WINTYPE% = 4 THEN
            BADOPS% = 50
            BadOpSys
        ENDIF
    ELSEIF WINTYPE% = 1 THEN
        BADOPS% = 50
        BadOpSys
    ENDIF

    ''Make Our Default drive and path string
    WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
    DESTDIR$ = WINDRIVE$ + DEFDIR$

    '' Set /O switch if on comand line
    SETUPTYPE$ = GetIniKeyString(SRCDIR$ + "setup.lst","SetupType","OEM")

    IF SETUPTYPE$ = "TRUE" THEN
        OEMTYPE% = 1
    ELSE
        OEMTYPE% = 0
    ENDIF

    '' Kill Old Pointer   This stuff is in \common\win\inc\pointer.h
    kbd& = PostMessage(FindWindow("POINTEXE","Pointer.exe Invisible Window"), 1133, 0, 0)
    '' Kill Real Old Pointer
    kd& = PostMessage(FindWindow("GROWSTUB",NULL),16,0,0)

    '' Kill Keyboard or Mouse managers
    x% = RegisterWindowMessage("PROPWINSHUTDOWN")
    kd& = PostMessage(-1,x%,0,0)

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB BadOpSys STATIC

    sz$ = UIStartDlg(COMDLL$, BADOPS%, "FQuitDlgProc", 0, "")
    UIPopAll
    END

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB Notadmini STATIC

    sz$ = UIStartDlg(COMDLL$, NOTADMIN, "FQuitDlgProc", 0, "")
    UIPopAll
    END

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB Disinsentive STATIC

    IF RetCode% = DIS_NOT_INSTALLED THEN

REDOO:
        sz$ = UIStartDlg(COMDLL$, CDGETNAME, "FNameOrgDlgProc", 0, "")
        szName$ = GetSymbolValue("NameOut")
        szOrg$ = GetSymbolValue("OrgOut")

        IF sz$ = "CONTINUE" THEN
            AddListItem "ConfirmTextIn", szName$
            AddListItem "ConfirmTextIn", szOrg$

            sz$ = UIStartDlg(COMDLL$, CDCONFIRMINFO, "FConfirmDlgProc", 0, "")
        
            RemoveSymbol "ConfirmTextIn"                                
            
            IF sz$ = "BACK" THEN
                UIPop(1)
                GOTO REDOO
            ELSE
                UIPop(2)
            ENDIF

        ELSEIF sz$ = "EXIT" THEN
        
            ASKEXIT
            
            GOTO REDOO

        ENDIF

        SetSymbolValue "INSTALLEDNAME", szName$ 
        SetSymbolValue "INSTALLEDORG", szOrg$ 
        sx% = WriteDisToFile(SRCDIR$ + "setup.ini")
        
    ELSEIF RetCode% = DIS_INSTALLED THEN

DISINSTALLED:
        szName$ = GetSymbolValue("INSTALLEDNAME")
        szOrg$ = GetSymbolValue("INSTALLEDORG")
        szSer$ = GetSymbolValue("INSTALLEDSER")

        AddListItem "ConfirmTextIn", szName$
        AddListItem "ConfirmTextIn", szOrg$
        AddListItem "ConfirmTextIn", szSer$

        sz$ = UIStartDlg(COMDLL$, CDALREADYUSED, "FConfirmDlgProc", 0, "")
        RemoveSymbol "ConfirmTextIn"                                

        IF sz$ = "EXIT" THEN
            ASKEXIT

            GOTO DISINSTALLED

        ELSE
            UIPop(1)
        ENDIF

    ELSEIF RetCode% = DIS_CORUPTED THEN

DISCORUPTED:
        sz$ = UIStartDlg(COMDLL$, CDBADFILE, "FInfoDlgProc", 0, "")

        IF sz$ = "EXIT" THEN
            ASKEXIT

            GOTO DISCORUPTED

        ELSE
            UIPop(1)
        ENDIF

    ENDIF

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB FindOldSoftWare STATIC

    DLG% = DESTPATH
    Cursor% = ShowWaitCursor()
 
    sz$ = GetEnvVariableValue("MSINPUT")
    IF sz$ <> "" THEN
        IF FindFileUsingFileOpen(MakePath(sz$,"POINTER.EXE")) <> "" THEN
            DESTDIR$ = sz$
            DLG% = PREINSTALLED
        ENDIF
    ENDIF

    RestoreCursor Cursor%

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB GetPath STATIC

    IF DLG% = PREINSTALLED THEN
        '' Do you realy want to?
        sz$ = UIStartDlg(COMDLL$, WARNING, "FConfirmDlgProc", 0, "")
        UIPop 1
        IF sz$ = "CONTINUE" THEN
            GOTO XSTALL
        END IF
    ENDIF

    SetSymbolValue "EditTextIn", DESTDIR$
    SetSymbolValue "EditFocus", "ALL"

GETPATHL1:

    sz$ = UIStartDlg(COMDLL$, DLG%, "FEditDlgProc", 0, "")

    IF sz$ = "CONTINUE" THEN
        DESTDIR$ = GetSymbolValue("EditTextOut")

        IF IsDirWritable(DESTDIR$) = 0 THEN
BADPATH:
            sz$ = UIStartDlg(COMDLL$, BADPATH, "FInfo0DlgProc", 0, "")
            IF sz$ = "REACTIVATE" THEN
                GOTO BADPATH
            END IF
            UIPop 1

            GOTO GETPATHL1

        END IF
RMBACK:
        IF MID$(DESTDIR$, LEN(DESTDIR$), 1) = "\" THEN
            IF LEN(DESTDIR$) > 3 THEN
                DESTDIR$ = MID$(DESTDIR$, 1, LEN(DESTDIR$)-1)
                GOTO RMBACK
            ENDIF
        ENDIF

        UIPop 1

    ELSEIF sz$ = "REACTIVATE" THEN
        GOTO GETPATHL1
    ELSEIF sz$ = "BACK" THEN
        x% = WinHelp(TKWIN%,SETUPINF$ + "PTSETUP.HLP", 1, 32)
        GOTO GETPATHL1
    ELSE
        ASKEXIT

        GOTO GETPATHL1

    END IF

XSTALL:

END SUB
'**************************************************************************

'*************************************************************************
'*************************************************************************
SUB QuitInstall STATIC

    IF ERR = 0 THEN
        sz$ = UIStartDlg(COMDLL$, EXITSUCCESS, "FInfoDlgProc", 0, "")

        IF sz$ = "EXIT" THEN
            x% = PostMessage(HWIN%, 2048, 100, 0)  
            END
        ELSEIF sz$ = "BACK" THEN
            x% = PostMessage(HWIN%, 2048, 100, 1)  
            END
        ELSE
            END
        END IF

        UIPop 1
        END

    ELSEIF ERR = STFQUIT THEN
        dlg% = EXITQUIT
    ELSE
        dlg% = EXITFAILURE
    END IF
QUITL1:
    sz$ = UIStartDlg(COMDLL$, dlg%, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
        GOTO QUITL1
    END IF
    UIPop 1
    x% = PostMessage(HWIN%, 2048, 100, 0)  
    
    END
 
    
END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
    IF szDir$ = "" THEN
        MakePath = szFile$
    ELSEIF szFile$ = "" THEN
        MakePath = szDir$
    ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
        MakePath = szDir$ + szFile$
    ELSE
        MakePath = szDir$ + "\" + szFile$
    END IF                 
END FUNCTION
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB ASKEXIT STATIC
ASKQUIT:
    sz$ = UIStartDlg(COMDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
    IF sz$ = "EXIT" THEN
        UIPopAll
        ERROR STFQUIT
    ELSEIF sz$ = "REACTIVATE" THEN
        GOTO ASKQUIT
    ELSE
        UIPop 1
    END IF

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB FillCopyList STATIC

    ClearCopyList
    LangType& = SendMessage(HWIN%, 2089, 0, 0)

    
    IF CUSTOM1$ = "ON" THEN
        AddSectionKeyFileToCopyList MOTYPE$, "ZA", SRCDIR$, MSENV$
        AddSectionKeyFileToCopyList MOTYPE$, "ZB", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList MOTYPE$, "ZC", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList MOTYPE$, "ZD", SRCDIR$, MSENV$

        IF POINTER1$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "A", SRCDIR$, DESTDIR$
            AddSectionKeyFileToCopyList "Cursor", "B", SRCDIR$, DESTDIR$ + "\EFFECTS"
        ENDIF

        IF POINTER2$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "B", SRCDIR$, DESTDIR$
        ENDIF

        IF POINTER3$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "C", SRCDIR$, DESTDIR$
        ENDIF

        IF POINTER4$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "D", SRCDIR$, DESTDIR$
        ENDIF

        IF POINTER5$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "E", SRCDIR$, DESTDIR$
        ENDIF

        IF POINTER6$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "F", SRCDIR$, DESTDIR$
            AddSectionKeyFileToCopyList "Cursor", "A", SRCDIR$, DESTDIR$ + "\EFFECTS"
        ENDIF

        IF POINTER7$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "G", SRCDIR$, DESTDIR$
        ENDIF

        IF POINTER8$ = "ON" THEN
            AddSectionKeyFileToCopyList MOTYPE$, "H", SRCDIR$, DESTDIR$
        ENDIF
    ENDIF

    IF CUSTOM2$ = "ON" THEN
        AddSectionKeyFileToCopyList MOTYPE$, "T", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList MOTYPE$, "U", SRCDIR$, DESTDIR$
    ENDIF

    IF CUSTOM3$ = "ON" THEN
        AddSectionKeyFileToCopyList "MiscDos", "B", SRCDIR$, DESTDIR$
        IF LangType = 65 THEN
            AddSectionKeyFileToCopyList "DosLan", "A", SRCDIR$, DESTDIR$
        ELSEIF LangType = 66 THEN
            AddSectionKeyFileToCopyList "DosLan", "B", SRCDIR$, DESTDIR$
        ELSEIF LangType = 67 THEN
            AddSectionKeyFileToCopyList "DosLan", "C", SRCDIR$, DESTDIR$
        ELSEIF LangType = 68 THEN
            AddSectionKeyFileToCopyList "DosLan", "D", SRCDIR$, DESTDIR$
        ELSEIF LangType = 69 THEN
            AddSectionKeyFileToCopyList "DosLan", "E", SRCDIR$, DESTDIR$
        ENDIF
    ENDIF

    IF CUSTOM4$ = "ON" THEN
        AddSectionKeyFileToCopyList "MiscDos", "A", SRCDIR$, DESTDIR$
        IF LangType = 65 THEN
            AddSectionKeyFileToCopyList "MiscDos", "ZA", SRCDIR$, DESTDIR$
        ELSEIF LangType = 66 THEN
            AddSectionKeyFileToCopyList "MiscDos", "ZB", SRCDIR$, DESTDIR$
        ELSEIF LangType = 67 THEN
            AddSectionKeyFileToCopyList "MiscDos", "ZC", SRCDIR$, DESTDIR$
        ELSEIF LangType = 68 THEN
            AddSectionKeyFileToCopyList "MiscDos", "ZD", SRCDIR$, DESTDIR$
        ELSEIF LangType = 69 THEN
            AddSectionKeyFileToCopyList "MiscDos", "ZE", SRCDIR$, DESTDIR$
        ENDIF
    ENDIF

    IF CUSTOM5$ = "ON" THEN
        AddSectionKeyFileToCopyList "Common", "AA", SRCDIR$, DESTDIR$ 
        IF LangType = 65 THEN
            AddSectionKeyFileToCopyList "Common", "A", SRCDIR$, DESTDIR$ 
        ELSEIF LangType = 66 THEN
            AddSectionKeyFileToCopyList "Common", "B", SRCDIR$, DESTDIR$ 
        ELSEIF LangType = 67 THEN
            AddSectionKeyFileToCopyList "Common", "C", SRCDIR$, DESTDIR$ 
        ELSEIF LangType = 68 THEN
            AddSectionKeyFileToCopyList "Common", "D", SRCDIR$, DESTDIR$ 
        ELSEIF LangType = 69 THEN
            AddSectionKeyFileToCopyList "Common", "E", SRCDIR$, DESTDIR$ 
        ENDIF
    ENDIF

    IF CUSTOM6$ = "ON" THEN
        IF MISC1$ = "ON" THEN
            AddSectionKeyFileToCopyList "Misc", "A", SRCDIR$, DESTDIR$
        ENDIF

        IF MISC2$ = "ON" THEN
            AddSectionKeyFileToCopyList "Misc", "B", SRCDIR$, DESTDIR$
        ENDIF
    ENDIF

    ini$ = GetWindowsDir

    IF LangType = 65 THEN
        AddIfVersion  "WinLan", "A", SRCDIR$, ini$
        AddSectionKeyFileToCopyList "Common", "K", SRCDIR$, DESTDIR$
    ELSEIF LangType = 66 THEN
        AddIfVersion "WinLan", "B", SRCDIR$, ini$
        AddSectionKeyFileToCopyList "Common", "L", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList "Write", "L", SRCDIR$, DESTDIR$
    ELSEIF LangType = 67 THEN
        AddIfVersion "WinLan", "C", SRCDIR$, ini$
        AddSectionKeyFileToCopyList "Common", "M", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList "Write", "M", SRCDIR$, DESTDIR$
    ELSEIF LangType = 68 THEN
        AddIfVersion "WinLan", "D", SRCDIR$, ini$
        AddSectionKeyFileToCopyList "Common", "N", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList "Write", "N", SRCDIR$, DESTDIR$
    ELSEIF LangType = 69 THEN
        AddIfVersion "WinLan", "E", SRCDIR$, ini$
        AddSectionKeyFileToCopyList "Common", "O", SRCDIR$, DESTDIR$
        AddSectionKeyFileToCopyList "Write", "O", SRCDIR$, DESTDIR$
    ENDIF
        
    szThe$ = GetVersionOfFile(GetWindowsDir +"SYSTEM\CTL3DV2.DLL")
    IF Copy3D(szThe$) = 1 THEN
        AddSectionFilesToCopyList "Sys16", SRCDIR$, GetWindowsDir +"SYSTEM"
    ENDIF    
    AddSectionFilesToCopyList "MsCom", SRCDIR$, MSENV$
    AddSectionFilesToCopyList "Win16drv", SRCDIR$, MSENV$
    AddIfVersion "Win16", "A", SRCDIR$, MSENV$
    AddIfVersion "Win16", "B", SRCDIR$, MSENV$
    AddSectionKeyFileToCopyList "Common", "X", SRCDIR$, DESTDIR$


END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB FillIniFile STATIC

    ini$ = MakePath(GetWindowsDir(), "SYSTEM.INI")
    szSec$ = "keyboard"

    IF WINTYPE% = 3 THEN
        CreateIniKeyValue ini$, "386Enh", szSec$, MakePath(MSENV$,"msinput.386"), cmoOverwrite
        CreateIniKeyValue ini$, "386Enh", "mouse", "*vmd", cmoOverwrite
    ENDIF
    CreateIniKeyValue ini$, "boot", "mouse.drv", MakePath(MSENV$,"MSINPUT.DRV"), cmoOverwrite
    CreateIniKeyValue ini$, "boot.description", "mouse.drv", "Microsoft IntelliPoint version 1.0", cmoOverwrite

    ini$ = MakePath(MSENV$,"MSINPUT.INI")
    CreateIniKeyValue ini$, "Directories", "Mouse", DESTDIR$, cmoOverwrite
    
    szSec$ = "Mouse"
    UpDateIniKeyValue ini$, szSec$, "ClickLock", "0"
    UpDateIniKeyValue ini$, szSec$, "RotationAngle", "0"
    IF 1 = SwapMouseButton(0) THEN
        x% = SwapMouseButton(1)
        x% = WriteProfileString("windows", "SwapMouseButtons", "no")
        UpDateIniKeyValue ini$, szSec$, "PrimaryButton", "3"
        UpDateIniKeyValue ini$, szSec$, "SecondaryButton", "1"
    ELSE
        UpDateIniKeyValue ini$, szSec$, "PrimaryButton", "1"
        UpDateIniKeyValue ini$, szSec$, "SecondaryButton", "3"
    ENDIF
    UpDateIniKeyValue ini$, szSec$, "HorizontalSensitivity", "50"
    UpDateIniKeyValue ini$, szSec$, "VerticalSensitivity", "50"
    CreateIniKeyValue ini$, szSec$, "ActiveAccelerationProfile", "2", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "SplashScreen", "ON", cmoOverwrite

    szSec$ = "WindowsPointer"
    UpDateIniKeyValue ini$, szSec$, "SnapTo", "OFF"
    UpDateIniKeyValue ini$, szSec$, "ScreenWrap", "OFF"
    UpDateIniKeyValue ini$, szSec$, "PointerSize", ""
    UpDateIniKeyValue ini$, szSec$, "PointerColor", ""
    UpDateIniKeyValue ini$, szSec$, "Growth", ""
    UpDateIniKeyValue ini$, szSec$, "Threshold", ""
    UpDateIniKeyValue ini$, szSec$, "Delay", ""
    CreateIniKeyValue ini$, szSec$, "Sonar", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "Locate", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "SlowMotion", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "ClickSaver", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "PointerHide", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "LineLock", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "AppScroller", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "Chord", "OFF", cmoNone
    CreateIniKeyValue ini$, szSec$, "Secondary", "OFF", cmoNone

    szSec$ = "ToolBar"
    CreateIniKeyValue ini$, szSec$, "AlwaysOnTop", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ReturnFocus", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "HideTitleBar", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "MinimizeOnUse", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ToolTips", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ToolbarPositionX", "140", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ToolbarPositionY", "125", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ToolbarRows", "1", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ToolbarColumns", "6", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "MagnifyBtn", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "AppScrollBtn", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "LineLockBtn", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "MouseSoundBtn", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "AlternateButtonBtn", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "Trails", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ClickLockBtn", "OFF", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "ControlPanelBtn", "ON", cmoOverwrite
    CreateIniKeyValue ini$, szSec$, "HelpBtn", "ON", cmoOverwrite

    x% = SetSchemes (ini$)

    ini$ = ""
    szSec$ = ""

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB SetPointStatus (TypeOp$, KeyOp$) STATIC

    if TypeOp$ = "ON" THEN
        POINTCOST& = POINTCOST& + GetSectionKeySize(MOTYPE$, KeyOp$)
    ELSE
        POINTCOST& = POINTCOST& - GetSectionKeySize(MOTYPE$, KeyOp$)
        IF POINTCOST& < 0 THEN
            POINTCOST& = 0
        ENDIF
    ENDIF

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB SetMiscStatus (TypeOp$, KeyOp$) STATIC

    if TypeOp$ = "ON" THEN
        MISCCOST& = MISCCOST& + GetSectionKeySize("Misc", KeyOp$)
    ELSE
        MISCCOST& = MISCCOST& - GetSectionKeySize("Misc", KeyOp$)
        IF MISCCOST& < 0 THEN
            MISCCOST& = 0
        ENDIF
    ENDIF

END SUB
'*************************************************************************

'**
'** Purpose:
'**     Sets drive status info according to latest disk space calcs.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB SetDriveStatus STATIC

    drive$ = MID$(DESTDIR$, 1, 1)
    ReplaceListItem DRIVETEXT$, 1, DESTDIR$
    free& = COSTLIST& + POINTCOST& + TOOLCOST& + DOSDRV& + DOSPOINT& + ONHELP& + MISCCOST&
    ReplaceListItem DRIVETEXT$, 2, STR$(free& / 1024) + " K"
    free& = GetFreeSpaceForDrive(drive$)
    ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"

END SUB

'*************************************************************************
'*************************************************************************
SUB AddIfVersion (szSec$, szKey$, szSrc$, szDest$) STATIC

    ver% = 1
    szOurs$ = GetSectionKeyVersion (szSec$,szKey$)
    szTheres$ = MakePath(szDest$, GetSectionKeyFilename(szSec$,szKey$))
    szTheres$ = GetVersionOfFile(szTheres$)

    IF GetVersionNthField (szOurs$, 1) < GetVersionNthField (szTheres$, 1) THEN
        ver% = 0
    ELSEIF GetVersionNthField (szOurs$, 1) = GetVersionNthField (szTheres$, 1) THEN
        IF GetVersionNthField (szOurs$, 2) < GetVersionNthField (szTheres$, 2) THEN
            ver% = 0
        ELSEIF GetVersionNthField (szOurs$, 2) = GetVersionNthField (szTheres$, 2) THEN
            IF GetVersionNthField (szOurs$, 3) < GetVersionNthField (szTheres$, 3) THEN
                ver% = 0
            ELSEIF GetVersionNthField (szOurs$, 3) = GetVersionNthField (szTheres$, 3) THEN
                IF GetVersionNthField (szOurs$, 4) < GetVersionNthField (szTheres$, 4) THEN
                    ver% = 0
                ENDIF
            ENDIF
        ENDIF
    ENDIF

    IF ver% = 1 THEN
        AddSectionKeyFileToCopyList szSec$, szKey$, szSrc$, szDest$
    ENDIF

END SUB

'*************************************************************************
'*************************************************************************
SUB UpDateIniKeyValue (szIni$, szSec$, szKey$, szVal$) STATIC

    sz$ = GetEnvVariableValue("MOUSE")

    IF sz$ = "" THEN
        CreateIniKeyValue szIni$, szSec$, szKey$, szVal$, cmoOverwrite
    ELSE
        xval$ = GetIniKeyString(MakePath(sz$ ,"MOUSE.INI"), szSec$, szKey$)
        IF xval$ = "" THEN
            CreateIniKeyValue szIni$, szSec$, szKey$, szVal$, cmoOverwrite
        ELSE
            CreateIniKeyValue szIni$, szSec$, szKey$, xval$, cmoOverwrite
        ENDIF
    ENDIF

END SUB

